$(function(){
	//刚开始加载
	var $input=$("input[name=level]");
	$input.each(function(){
		if ($(this).attr("value")==$("#powerLevel").attr("value")){
			$(this).attr("checked","checked");
		}
	})
	getlevel();
	$(".tiaozheng2").change(function() {
		getlevel();
	});
})


function getlevel(){
	var $selectedvalue = $("input[name='level']:checked").val();
	if ($selectedvalue =='1') {
		 $('#select').empty();
		 return;
	}if ($selectedvalue =='2') {
		$.ajax({
	        type: "post",
	        url: "manager_getallpowers",
	        data: {level:1},
	        dataType: "json",
	        success: function(data){
	                    $('#select').empty();   //清空select里面的所有内容
	                    var html = ''; 
	                    $.each(eval(data), function(i,msg){
	                    	$("#select").append("<option value="+msg.id+">"+msg.name+"</option>");
	                    });
	                 }
	    });
	}else {
		$.ajax({
	        type: "post",
	        url: "manager_getallpowers",
	        data: {level:2},
	        dataType: "json",
	        success: function(data){
	                    $('#select').empty();   //清空select里面的所有内容
	                    var html = ''; 
	                    $.each(eval(data), function(i,msg){
	                    	$("#select").append("<option value="+msg.id+">"+msg.name+"</option>");
	                    });
	                 }
	    });
	}
}